package com.car.loan.project.xr.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.Collection;
import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.car.loan.project.xr.mapper.CustomerMapper;
import com.car.loan.project.xr.domain.Customer;
import com.car.loan.project.xr.service.ICustomerService;

/**
 * 客户基本信息Service业务层处理
 *
 * @author ruoyi
 * @date 2019-11-03
 */
@Service
public class CustomerServiceImpl implements ICustomerService {

    @Autowired
    private CustomerMapper customerMapper;

    /**
     * 查询客户基本信息
     *
     * @param id 客户基本信息ID
     * @return 客户基本信息
     */
    @Override
    public Customer selectCustomerById(Long id) {
        return customerMapper.selectById(id);
    }

    /**
     * 查询客户基本信息列表
     *
     * @param customer 客户基本信息
     * @return 客户基本信息
     */
    @Override
    public List<Customer> selectCustomerList(Customer customer) {
        QueryWrapper<Customer> queryWrapper = new QueryWrapper<>(customer);
        return customerMapper.selectList(queryWrapper);
    }


    @Override
    public IPage<Customer> selectPage(IPage<Customer> page, QueryWrapper<Customer> queryWrapper) {
        return customerMapper.selectPage(page, queryWrapper);
    }

    /**
     * 新增客户基本信息
     *
     * @param customer 客户基本信息
     * @return 结果
     */
    @Override
    public int insertCustomer(Customer customer) {

        return customerMapper.insert(customer);
    }

    /**
     * 修改客户基本信息
     *
     * @param customer 客户基本信息
     * @return 结果
     */
    @Override
    public int updateCustomer(Customer customer) {

        return customerMapper.updateById(customer);
    }

    /**
     * 删除客户基本信息对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCustomerByIds(Collection<Long> ids) {
        return customerMapper.deleteBatchIds(ids);
    }

    /**
     * 删除客户基本信息信息
     *
     * @param id 客户基本信息ID
     * @return 结果
     */
    @Override
    public int deleteCustomerById(Long id) {
        return customerMapper.deleteById(id);
    }
}
